﻿using Microsoft.VisualStudio.Modeling;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;

using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace Project.Co_DataTransformationPrototype.UI
{
    public partial class SelectAttributeForm : Form
    {
        private Entity target;
        public EntityAttribute foreignKeyAttribute;

        public SelectAttributeForm(Entity target)
        {
            this.target = target;
            InitializeComponent();
        }      

        private void SelectAttributeForm_Load(object sender, EventArgs e)
        {
            this.Text += target.CurrentName + " Entity";
            cboAttributes.Items.AddRange(target.EntityAttributes.OrderBy(a => a.CurrentName).ToArray());
        }
        
        private void btnSelect_Click(object sender, EventArgs e)
        {
            if (cboAttributes.SelectedItem != null)
            {
                foreignKeyAttribute = cboAttributes.SelectedItem as EntityAttribute;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
    }
}
